<?php
// 修复打卡积分菜单的URL字段
$host = '127.0.0.1';
$port = 3306;
$database = 'qiandao';
$username = 'root';
$password = 'root';

try {
    $pdo = new PDO("mysql:host={$host};port={$port};dbname={$database};charset=utf8mb4", $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    echo "=== 修复打卡积分菜单的URL字段 ===\n\n";
    
    // 更新所有打卡积分的三级菜单，将node复制到url
    $updates = [
        27 => 'checkin/store/index',
        29 => 'checkin/member/index',
        31 => 'checkin/record/index',
        33 => 'checkin/gift/index',
        35 => 'checkin/exchange/index',
        37 => 'checkin/setting/index',
    ];
    
    foreach ($updates as $id => $url) {
        $stmt = $pdo->prepare("UPDATE system_menu SET url = ? WHERE id = ?");
        $stmt->execute([$url, $id]);
        echo "✓ 更新菜单 ID:{$id}, URL:'{$url}'\n";
    }
    
    echo "\n✅ 所有菜单URL已更新！\n";
    echo "\n现在请：\n";
    echo "1. 刷新浏览器（按 F5）\n";
    echo "2. 查看左侧菜单\n";
    echo "3. 应该能看到'打卡积分'菜单了！\n";
    
} catch (PDOException $e) {
    echo "错误: " . $e->getMessage() . "\n";
}

